package acm;


import java.io.IOException;

import java.io.InputStreamReader;

import java.io.Reader;

import java.util.HashMap;

import java.util.Map.Entry;



public class 测试 {

    private static Reader reader;



    public static void main(String[] args) {

        reader = new InputStreamReader(System.in);

        int n, m;

        n = getInt();

        m = getInt();

        HashMap<Integer, Integer> hm = new HashMap<>(n);

        for (int i = 0; i < n; ++i) {

            int num = 0, x = 0;

            for (int j = 0; j < m; j++) {

                x = getInt();

                num = (num << 1) + x;

            }

            hm.put(num, hm.containsKey(num) ? hm.get(num) + 1 : 1);

        }

        int sum = 0, maxn = (1 << m) - 1;

        for (Entry<Integer, Integer> entry : hm.entrySet()) {

            if (maxn / 2 < entry.getKey())

                continue;

            int key = entry.getKey() ^ maxn;

            if (hm.containsKey(key))

                sum += hm.get(key) * entry.getValue();

        }

        System.out.println(sum);

    }



    public static int getInt() {

        int res = 0, read;

        try {

            while ((read = reader.read()) != -1) {

                if (Character.isDigit(read)) {

                    res = read - '0';

                    while ((read = reader.read()) != -1) {

                        if (Character.isDigit(read)) {

                            res = res * 10 + (read - '0');

                        } else {

                            break;

                        }

                    }

                    break;

                }

            }

        } catch (IOException e) {



            e.printStackTrace();

        }

        return res;

    }

}
